<?php

namespace app\admin\model;

use app\common\model\TimeModel;

class Product extends TimeModel
{

    protected $name = "product";

    protected $deleteTime = false;

    protected $type = [

        'send_time'  =>  'timestamp:Y/m/d H:i:s',
        'give_time'  =>  'timestamp:Y/m/d H:i:s',
        'ai_time'  =>  'timestamp:Y/m/d H:i:s',
        'accepted_time'  =>  'timestamp:Y/m/d H:i:s',
        'aitask_get_time'  =>  'timestamp:Y/m/d H:i:s',

    ];


    public function adminuser()
    {
        return $this->belongsTo('\app\admin\model\SystemAdmin','admin_id','id');
    }

    public function category()
    {
        return $this->belongsTo('\app\admin\model\Category', 'category_id', 'id');
    }

    public function rule()
    {
        return $this->belongsTo('\app\admin\model\Rule', 'rule_id', 'id');
    }
    public function supplier()
    {
        return $this->belongsTo('\app\admin\model\Supplier', 'supplier_id', 'id');
    }

    public function suppliers()
    {
        return $this->hasMany('\app\admin\model\ProductSupplier','product_id','id');
    }

    public function productMaps()
    {
        return $this->belongsTo('\app\admin\model\ProductMaps','product_map_id','id');
    }


//    远程 一对多
    public function suppliersname()
    {
        return $this->hasManyThrough('\app\admin\model\Supplier','\app\admin\model\ProductSupplier','product_id','id','id');
    }

    

}